package com.qf.controller;

import com.qf.feign.SearchFeign;
import com.qf.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 测试使用远程调用feign技术
 * @author 千锋健哥
 */
@RestController
@RequestMapping("/test2")
public class TestFeignController {

    @Autowired
    private SearchFeign searchFeign;

    /**
     * 测试get请求远程调用
     * @return
     */
    @GetMapping("/t1")
    public String test1() {
        String test = searchFeign.test();
        return test;
    }

    @GetMapping("/findbyName")
    public List<User> findUserByName(String name) {
        List<User> byName = searchFeign.findByName(name);
        return byName;
    }

    @GetMapping("/update")
    public String update() {
        User user = new User();
        user.setId(2);
        user.setName("李四");
        searchFeign.updateUser(user);
        return "修改成功";
    }
}
